package top.ivansong92.example.leetcode.learning.data.struct.array.extension.stack;

import top.ivansong92.example.leetcode.learning.data.struct.array.extension.NewArrayV2;

public class NewArrayStack<T> implements NewStack<T> {

    private NewArrayV2<T> array;

    public NewArrayStack(int initSize) {
        this.array = new NewArrayV2<>(initSize);
    }

    @Override
    public int getSize() {
        return 0;
    }

    @Override
    public boolean isEmpty() {
        return array.size() == 0;
    }

    @Override
    public void push(T e) {
        array.addLast(e);
    }

    @Override
    public T pop() {
        return array.removeLast();
    }

    @Override
    public T peek() {
        return array.getLast();
    }

    @Override
    public String toString() {
        return "NewArrayStack{" + array +
                '}';
    }
}
